home *** CD-ROM | disk | FTP | other *** search
/ PCGUIA 127 / PC Guia 127.iso / Software / Produtividade / OpenOffice.org 2.0.1 / openofficeorg4.cab / test_nis.py < prev    next >
Text File  |  2005-11-19  |  847b  |  33 lines

  1. from test.test_support import verbose, TestFailed, TestSkipped
  2. import nis
  3.  
  4. print 'nis.maps()'
  5. try:
  6.     maps = nis.maps()
  7. except nis.error, msg:
  8.     # NIS is probably not active, so this test isn't useful
  9.     if verbose:
  10.         raise TestFailed, msg
  11.     # only do this if running under the regression suite
  12.     raise TestSkipped, msg
  13.  
  14. done = 0
  15. for nismap in maps:
  16.     if verbose:
  17.         print nismap
  18.     mapping = nis.cat(nismap)
  19.     for k, v in mapping.items():
  20.         if verbose:
  21.             print '    ', k, v
  22.         if not k:
  23.             continue
  24.         if nis.match(k, nismap) != v:
  25.             print "NIS match failed for key `%s' in map `%s'" % (k, nismap)
  26.         else:
  27.             # just test the one key, otherwise this test could take a
  28.             # very long time
  29.             done = 1
  30.             break
  31.     if done:
  32.         break
  33.